package co.edu.unal.geditor.model;

import java.awt.Graphics;
import java.awt.Point;
import java.util.ArrayList;

import co.edu.unal.geditor.controller.App;
import co.edu.unal.geditor.view.ElementView;

public class PolyLineElement extends GraphElement {

	public PolyLineElement(Point pUl, Point pBd) {
		super(pUl,pBd);
		m_arrLines.add(new LineElement(pUl, pBd));
	}
	@Override
	public boolean isPolyLine(){
		return true;
	}
	public void addLine(Point newPoint) {
		m_arrLines.add(new LineElement(m_arrLines.get(m_arrLines.size()-1).getDownRight(),newPoint));
	}

	@Override
	protected ElementView createView() {
		return null;
	}
	@Override
	public void paint(Graphics g) {
		for (LineElement le : m_arrLines){
			le.paint(g);
		}
	}
	@Override
	public boolean contain(Point ptContain) {
		boolean retorno = true;
		for(LineElement le : m_arrLines){
			retorno&=le.contain(ptContain);
		}
		if (retorno) {
			App.getInstance().getCanvas().setActiveFeedbackGraphElement(this);
		}
		return retorno;
	}
	@Override
	public boolean select(BoundBox bb) {
		boolean retorno=true;
		for(LineElement le : m_arrLines){
			retorno&=le.select(bb);
		}
		return retorno;
	}

	private ArrayList<LineElement> m_arrLines = new ArrayList<LineElement>();
}
